home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
3_16.lha
/
3_16
/
3_16a.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-08
|
783b
|
45 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
/ Strip all C++ comments
/ from a source file read
/ on the standard input.
include <stream.h>
nt main(int, char**)
char ch;
while (cin.get(ch))
{
// a / may be followed by another / or a *
if (ch == '/')
{
cin.get(ch);
if (!cin)
break;
if (ch == '/') dolinecomment();
else if (ch == '*') doblockcomment();
// if not one of the above, then it's
// not a comment and the 2nd character
// must be rescanned
else
{
cout.put('/');
cin.putback(ch);
}
}
else // a printable character
{
cout.put(ch);
if (ch == '"' || ch == '\'')
do_string_or_char(ch);
}
}
return 0;